<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对话</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-image: url("../static/background.png");
            background-size: cover;
            margin: 0;
            padding: 20px;
            text-align: center; /* Center-align text for all elements */
        }

        h1 {
            color: #6e30c6;
            margin-bottom: 30px;
        }

        form {
            background-color: #fff;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            display: inline-block; /* Make form centered */
            max-width: 100%;
        }

        #result {
            background-color: #fff;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            display: inline-block; /* Make form centered */
            max-width: 100%;
        }

        /*label {*/
        /*    display: block; !* Each label on its line *!*/
        /*    margin-bottom: 8px;*/
        /*}*/

        /*input[type="text"] {*/
        /*    width: calc(100% - 22px); !* Full width minus padding *!*/
        /*    padding: 10px;*/
        /*    margin-bottom: 15px;*/
        /*    border: 1px solid #ccc;*/
        /*    border-radius: 4px;*/
        /*}*/

        /*input[type="text"]:focus {*/
        /*    border-color: #007bff;*/
        /*    box-shadow: 0 0 8px rgba(0, 123, 255, 0.2);*/
        /*}*/

        .input {
            background-color: #212121;
            max-width: 190px;
            height: 40px;
            padding: 10px;
            /* text-align: center; */
            border: 2px solid white;
            border-radius: 5px;
            /* box-shadow: 3px 3px 2px rgb(249, 255, 85); */
        }

        .tiaojian {
            margin-top: 20px;
        }

        .input:focus {
            color: rgb(0, 255, 255);
            background-color: #212121;
            outline-color: rgb(0, 255, 255);
            box-shadow: -3px -3px 15px rgb(0, 255, 255);
            transition: .1s;
            transition-property: box-shadow;
        }


        button {
            margin-top: 30px;
            padding: 10px 20px;
            border: none;
            background-color: #007bff;
            color: white;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button:hover {
            background-color: #0056b3;
        }

        #loading {
            margin-top: 20px;
            color: #ffffff;
        }

        /* Responsive design for smaller screens */
        @media (max-width: 600px) {
            body {
                padding: 10px;
            }

            form {
                width: auto;
                margin: 0 10px; /* Adjust form margins on smaller screens */
            }
        }
    </style>
</head>
<body>
<h1>写一首诗</h1>
<form method="POST" onsubmit="showLoading()">
    <input placeholder="请输入关键词" id="product" class="input" name="product" type="text" required><br>
    <input placeholder="请输入条件（例如七言律诗）" id="tiaojian" class="input" name="tiaojian" type="text" required><br>
    <button type="submit">提交</button>
    <button type="submit" onclick="clearInput()">清除</button>
</form>
<div id="loading" style="display:none;">loading...</div>
{% if answer %}
<div style="margin-top: 20px; text-align: left;" id="result">
    <h2>结果：</h2>
    <p style="color:black;font-size:20px;">{{ answer }}</p>
</div>
{% endif %}
<script>
    function showLoading() {
        document.getElementById('loading').style.display = 'block';
    }

    function clearInput() {
        document.getElementById('product').value = '';
        document.getElementById('tiaojian').value = '';
    }
</script>
</body>
</html>